package com.hzeport.bgs22emduty.inbound.api;

import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenCheckQuestionsDTO;
import com.hzeport.bgs22emduty.dto.ScreenShouldKnowAnswerDTO;
import com.hzeport.bgs22emduty.dto.ScreenShouldKnowDTO;
import com.hzeport.bgs22emduty.entity.ScreenCheckQuestions;
import com.hzeport.bgs22emduty.entity.ScreenShouldKnowAnswer;
import com.hzeport.bgs22emduty.vo.ScreenCheckQuestions.ScreenCheckQuestionsSaveVO;
import com.hzeport.bgs22emduty.vo.ScreenShouldKnow.ScreenShouldKnowSaveVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.entity.ScreenShouldKnow;
import com.hzeport.bgs22emduty.service.ScreenShouldKnowService;
//import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screenshouldknow")
@Api(value = "screenshouldknow", tags = "应知应会管理")
@Slf4j
public class ScreenShouldKnowController {

    private final ScreenShouldKnowService screenShouldKnowService;

    @Resource
    private final LoginCompoentService loginCompoentService;

    @ApiOperation(value = "列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public  BaseResult<Page<ScreenShouldKnow>> list(@RequestBody ScreenShouldKnowDTO dto) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  screenShouldKnowService.list(dto,userInfoDetailVO);
    }


    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    @OperLog( systemName = "YZYH", description = "YZSC")
    public BaseResult removeById(@RequestParam("id") String id) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return screenShouldKnowService.delete(id,userInfoDetailVO);
    }

    @ApiOperation(value = "保存")
    @RequestMapping(value = "save",method = RequestMethod.POST)
    @OperLog( systemName = "YZYH", description = "YZBC")
    public BaseResult save(@RequestBody ScreenShouldKnowSaveVO screenShouldKnowSaveVO) throws Exception {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  screenShouldKnowService.saveData(screenShouldKnowSaveVO,userInfoDetailVO);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
    public BaseResult<ScreenShouldKnow> detail(@RequestParam("id") String id)  {
        return screenShouldKnowService.detail(id);
    }

    @ApiOperation(value = "获取答案列表")
    @RequestMapping(value = "answerList",method = RequestMethod.GET)
    public BaseResult<ScreenShouldKnowAnswer> answerList(@RequestBody ScreenShouldKnowAnswerDTO screenShouldKnowAnswerDTO) throws Exception {
        return screenShouldKnowService.answerList(screenShouldKnowAnswerDTO);
    }
}
